package com.ruoyi.back.service.impl

import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.back.domain.SpreadCenterSetting
import com.ruoyi.back.mapper.SpreadCenterSettingMapper
import com.ruoyi.back.service.SpreadCenterSettingService
import org.springframework.stereotype.Service

@Service
class SpreadCenterSettingServiceImpl : ServiceImpl<SpreadCenterSettingMapper, SpreadCenterSetting>(),
    SpreadCenterSettingService {


    override fun getSpreadCenterSetting(): Data<SpreadCenterSetting> = Ok(
        "获取成功", getOne(
            KtQueryWrapper(SpreadCenterSetting::class.java)
        )
    )

    override fun saveSpreadCenterSetting(spreadCenterSetting: SpreadCenterSetting): Data<Boolean> =
        spreadCenterSetting.id?.run {
            Ok("更新设置成功", updateById(spreadCenterSetting))
        } ?: Ok("保存设置成功", save(spreadCenterSetting))
}